package logic_control;

import java.util.Scanner;

public class Way {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入n: ");
        int n = scanner.nextInt();
        System.out.println(factorial(n));
    }

    public static int factorial(int n) {
        int j = 0;
        for (int m = n;m > 0;m--) {
            int k = 1;
            for (int i = 0;i < m;i++) {
                k *= i + 1;
            }
            j += k;
        }
        return j;
    }
}
